//
//  RootViewController.m
//  Newproject3
//
//  Created by rimi on 16/9/12.
//  Copyright © 2016年 Liang. All rights reserved.
//

#import "RootViewController.h"
#import "BrowseViewController.h"
#import "ViewController.h"
#import "SettingViewController.h"
@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatTabbar];
}

-(void)creatTabbar{
    UINavigationController *nav1 = [self tabbarAddViewControllers:[[BrowseViewController alloc]init] image:@"icon-我的@2x.png" tabbarName:@"浏览"];
    UINavigationController *nav2 = [self tabbarAddViewControllers:[[ViewController alloc]init] image:@"icon-我的@2x.png" tabbarName:@"玩玩"];
    UINavigationController *nav3 = [self tabbarAddViewControllers:[[SettingViewController alloc]init] image:@"icon-我的@2x.png" tabbarName:@"设置"];
    self.viewControllers = @[nav1,nav2,nav3];
    self.selectedIndex = 0;
    self.tabBar.tintColor = [UIColor cyanColor];
}

-(UINavigationController *)tabbarAddViewControllers:(UIViewController *)vc image:(NSString *)imageName tabbarName:(NSString *)tabbarName{
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    UIImage *tabImage = [UIImage imageNamed:imageName];
    vc.tabBarItem = [[UITabBarItem alloc]initWithTitle:tabbarName image:tabImage selectedImage:nil];
       return nav;
}

@end
